package router

import (
	"github.com/gin-gonic/gin"
	"test_gin/src/controller/test_vc"
	"test_gin/src/controller/user_vc"
	"test_gin/src/controller/web_vc"
)

func Run(addr ...string) (err error) {
	return routerInit().Run(addr...)
}

func routerInit() *gin.Engine {
	r := gin.Default()
	r.LoadHTMLGlob("templates/**/*")

	webRouter := r.Group("/")
	{
		webRouter.GET("/", web_vc.Index)
		webRouter.GET("/login", web_vc.Login)
	}

	userRouter := r.Group("/api/user")
	{
		userRouter.POST("/login", user_vc.Login)
	}

	testRouter := r.Group("/api/test")
	{
		testRouter.GET("/test_get", test_vc.TestGet)
		testRouter.POST("/test_post", test_vc.TestPost)
	}

	return r
}
